Change ordering LIFO to FIFO on delayed jobs#416
Change ordering LIFO to FIFO on delayed jobs#416mariocamaraneto wants to merge 1 commit intoyiisoft:masterfrom
Conversation
Push in left and pop from right
This is not true. Expired/delayed job will be executed after execution of all new jobs that were pushed in the meantime. So while order of execution may not match order of push (it was never a guarantee in queue), this job will eventually be executed. |
|
The delayed job added to the queue can change the order that they were pushed. Eventually the can be executed, but this may delay ther execution significantly. In servers with a high amount of delayed jobs being added to the queue, the jobs can be delayed for hours. I saw this happening in our servers, where new jobs were being processed almost immedietly, while old jobs were queued for hours. I attached a file with a simulation, where in the queue with delayed jobs we can see that job p3 can be stuck in waiting "forever" if new delayed jobs keeps being pushed. Like in "live lock". In queues without delay, all new jobs are pushed to the left and reserved in right. This is exactly I coded in this PR. |
|
I made a test to simulate this situation, but I don't like the solution because use many SLEEP and decrease the decreases the speed of tests. |
|
A test is necessary. Also please add a line for CHANGELOG. |
Push in left and pop from right
Without this we can have Live Lock because some Jobs added first never wil be attendend if new jobs won't stop arriving